﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.TradeChannel.Exceptions
{
    /// <summary>
    /// 由于交易通道产生的异常
    /// </summary>
    [Serializable]
    public class TradeChannelException : Exception
    {
        private readonly string channelId;

        public TradeChannelException(TradeChannelErrorCode errorCode, string channelId, string message)
            : base(message)
        {
            this.ErrorCode = errorCode;
            this.channelId = channelId;
        }

        /// <summary>
        /// 获取通道Id
        /// </summary>
        public string ChannelId
        {
            get
            {
                return channelId;
            }
        }


        public TradeChannelErrorCode ErrorCode { get; private set; }
    }

    public enum TradeChannelErrorCode
    {
        /// <summary>
        /// 签名引发的异常
        /// </summary>
        SignFail,
        /// <summary>
        /// 网络引发的异常
        /// </summary>
        Network,
        /// <summary>
        /// 客户端引发的异常
        /// </summary>
        ClientRequest,
        /// <summary>
        /// 客户端验证引发的异常
        /// </summary>
        ClientRequestValidation,
        /// <summary>
        /// 通道验证引发的异常
        /// </summary>
        ChannelValidataion,
        /// <summary>
        /// 配置引发的异常
        /// </summary>
        Configure,
        /// <summary>
        /// 接口错误引发的异常
        /// </summary>
        Interface
    }
}
